# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel:pl_build_system.bzl", "pl_go_binary", "pl_go_image")

go_library(
    name = "metadata_lib",
    srcs = ["metadata_server.go"],
    importpath = "px.dev/pixie/src/vizier/services/metadata",
    visibility = ["//visibility:private"],
    deps = [
        "//src/shared/goversion",
        "//src/shared/services",
        "//src/shared/services/election",
        "//src/shared/services/healthz",
        "//src/shared/services/httpmiddleware",
        "//src/shared/services/metrics",
        "//src/shared/services/server",
        "//src/vizier/services/metadata/controllers",
        "//src/vizier/services/metadata/controllers/agent",
        "//src/vizier/services/metadata/controllers/cronscript",
        "//src/vizier/services/metadata/controllers/k8smeta",
        "//src/vizier/services/metadata/controllers/tracepoint",
        "//src/vizier/services/metadata/metadataenv",
        "//src/vizier/services/metadata/metadatapb:service_pl_go_proto",
        "//src/vizier/utils/datastore",
        "//src/vizier/utils/datastore/etcd",
        "//src/vizier/utils/datastore/pebbledb",
        "@com_github_cockroachdb_pebble//:pebble",
        "@com_github_nats_io_nats_go//:nats_go",
        "@com_github_sirupsen_logrus//:logrus",
        "@com_github_spf13_pflag//:pflag",
        "@com_github_spf13_viper//:viper",
        "@io_etcd_go_etcd_client_pkg_v3//transport",
        "@io_etcd_go_etcd_client_v3//:client",
        "@io_k8s_api//core/v1:core",
        "@org_golang_google_grpc//:grpc",
    ],
)

pl_go_binary(
    name = "metadata",
    embed = [":metadata_lib"],
    visibility = ["//visibility:public"],
)

pl_go_image(
    name = "metadata_server_image",
    binary = ":metadata",
    visibility = [
        "//k8s:__subpackages__",
        "//src/vizier:__subpackages__",
    ],
)
